<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="test"></div>
    <script type="text/javascript" src="../js/react.development.js"></script>
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../js/babel.min.js"></script>
    <script type="text/javascript" src="../js/prop-types.js"></script>
    <script type="text/babel">
        class Login extends React.Component{
            state={
                username:'',
                password:''
            }
            saveFormData=(datatype,event)=>{
                    this.setState({[datatype]:event.target.value})
            }
            submit=(event)=>{
                event.preventDefault()
                const {username,password}=this.state
                console.log(username,password)
            }
            render(){
                return(
                    <form onSubmit={this.submit}>
                        用户名：<input onChange={event=>this.saveFormData('username',event)} type="text"/>
                        密码：<input onChange={event=>this.saveFormData('password',event)} type="text"/> 
                        <button>登录</button>   
                    </form>
                )
            }
        }

        ReactDOM.render(<Login/>,document.getElementById('test'))
    </script>
    </script>
</body>
</html>